package com.charlotte.gupao.study.springcloudalibabanacosweb.dubbo.demo.controller;

import com.charlotte.study.api.LogService;
import com.charlotte.study.dto.LogDto;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author junjie.ding
 * @date 2020/9/9 16:57
 * @description TODO
 */
@RestController
@RequestMapping("/log")
public class LogController {

    @Reference
    private LogService logService;

    @GetMapping("/insert")
    public String insertLog(){
        boolean insertLog = logService.insertLog(new LogDto(1, this.getClass().getName(), "日志信息"));
        return insertLog ? "插入日志成功" : "插入日志失败";
    }

    @GetMapping("/query")
    public String queryLog() {
        return logService.queryLog().toString();
    }
}
